<template>
  <Layout>
    <Form ref="form1" :model="form1" :label-width="120">

      <Row class="query-form" style="padding-top: 15px">
        <Col span="8">
          <FormItem label="审计计划：">
            <Select v-model="form1.auditPlanId" style="width: 100%" @on-change="selectCompany">
              <Option v-for="plan in jinyu" :key="plan.auditPlanId" :value="plan.auditPlanId">{{plan.auditPlanName}}</Option>
            </Select>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label='企业名称：'>
            <Select class="query-form-el" filterable v-model="form1.auditOrgId" placeholder="请先选择审计计划" >
                <Option v-for="item in companyList" :value="item.auditedOrgId" :key="item.auditedOrgName">{{ item.auditedOrgName }}</Option>
            </Select>
          </FormItem>
        </Col>
        <Col span="8">
          <Button class="ivu-btn-query" icon="md-search" @click="selects">查询</Button>
        </Col>
      </Row>
    </Form>
    <Row :gutter="10" class="card-row">
      <Col span="12">
        <Card dis-hover>
          <Spin fix v-if="problemShow">
            <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
            <div>Loading</div>
          </Spin>
          <p class="p-title">▎ </p>
          <p>问题统计</p>
          <div ref="problemNum" style="height: 300px;"></div>
        </Card>
      </Col>
      <Col span="12">
        <Card dis-hover>
          <Spin fix v-if="scoreStatisticsShow">
            <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
            <div>Loading</div>
          </Spin>
          <p class="p-title">▎ </p>
          <p>近三次审计问题变化曲线</p>
          <div ref="scoreStatistics" style="height: 300px;"></div>
        </Card>
      </Col>
    </Row>
    <Row :gutter="10" class="card-row">
      <Col span="12">
        <Card dis-hover>
          <Spin fix v-if="missionScoreShow">
            <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
            <div>Loading</div>
          </Spin>
          <p class="p-title">▎ </p>
          <p>得分</p>
          <!--          <div ref="missionScore" style="height: 300px;"></div>-->
          <Table ref='missionScore' :height="290" no-data-text="没有查询到相关数据！"
                 :loading="missionScoreShow" size="small" :columns="missionScoreTable"
                 :data="missionScoreList">
          </Table>
        </Card>
      </Col>
      <Col span="12">
        <Card dis-hover>
          <Spin fix v-if="groupGradeColumnShow">
            <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
            <div>Loading</div>
          </Spin>
          <p class="p-title">▎ </p>
          <p>企业历次审计问题数量趋势变化</p>
          <div ref="groupGradeColumn" style="height: 300px;"></div>
        </Card>
      </Col>
    </Row>
    <Row :gutter="10" class="card-row">
      <Col span="12">
        <Card dis-hover>
          <p class="p-title">▎ </p>
          <p>企业多次扣分内容</p>
          <Table ref='repeatDeductions' :height="290" no-data-text="没有查询到相关数据！"
                 :loading="repeatDeductionsShow" size="small" :columns="repeatDeductionsTable"
                 :data="repeatDeductionList">
          </Table>
        </Card>
      </Col>
      <Col span="12">
        <Card dis-hover>
          <p class="p-title">▎ </p>
          <p>扣分最高项目top5</p>
          <Table ref='deductionTop5' :height="290" no-data-text="没有查询到相关数据！"
                 :loading="deductionShow" size="small" :columns="deductionTop5Cloums" :data="deductionTop5List">
          </Table>
        </Card>
      </Col>
    </Row>
    <Modal :title="title" :transfer=false v-model="model1" :width=1200 footer-hide>
      <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据！"
             :loading="loading" size="small" border :columns="columns1" :data="dataTable">
      </Table>
      <Row style="margin-right:10px;">
        <Col span="24">
          <Page :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange"
                style="float: right" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                show-total show-sizer show-elevator/>
        </Col>
      </Row>
    </Modal>
  </Layout>
</template>

<script>
import {Api} from '../../../../api/index.js'
import {sessionStorage} from '../../../../common/cacheUtils.js';
import cascaderDom from '../../../../components/cascader-dom.vue';
import echarts from 'echarts';

export default {
  components: {cascaderDom},
  name: "riskStatical",
  data() {
    return {
      title: '',
      repeatDeductionsShow: false,
      missionScoreShow: false,
      deductionShow: false,
      deductionTop5List: [],
      missionScoreList: [],
      missionScoreTable: [
        {
          title: "序号",
          width: 80,
          align: "center",
          fixed: 'left',
          render: (h, params) => {
            return h('span', params.index + 1);
          }
        },
        {
          title: "审计计划",
          width: 140,
          align: "center",
          key: 'auditPlanName',
        },
        {
          title: '审计类型',
          minWidth: 110,
          align: 'center',
          key: 'auditType',
          tooltip: true,
        },
        {
          title: '审计得分',
          minWidth: 80,
          align: 'center',
          key: 'level',
          tooltip: true,
        },

      ],
      deductionTop5Cloums: [
        {
          title: "序号",
          width: 80,
          align: "center",
          fixed: 'left',
          render: (h, params) => {
            return h('span', params.index + 1);
          }
        },
        {
          title: "标准",
          width: 80,
          align: "center",
          key: 'problemTypeName',
        },
        {
          title: '审计项目',
          minWidth: 120,
          align: 'center',
          key: 'factorName',
          tooltip: true,
        },
        {
          title: '审计内容',
          minWidth: 120,
          align: 'center',
          key: 'subitemName',
          tooltip: true,
        },
        {
          title: '扣分',
          width: 90,
          align: 'center',
          key: 'auditScore',
        },

      ],
      repeatDeductionsTable: [
        {
          title: "类型",
          width: 80,
          align: "center",
          key: 'auditType',
          render: (h, params) => {
            if (params.row.auditType === '1') {
              return h('span', '基础');
            } else if (params.row.auditType === '2') {
              return h('span', '现场');
            }else if(params.row.auditType === '3'){
              return h('span', '班组');
            }

          }
        },
        {
          title: '扣分次数',
          width: 90,
          align: 'center',
          key: 'countNum',
        },
        {
          title: '审计内容',
          minWidth: 120,
          align: 'center',
          key: 'subitemName',
          tooltip:true,
        },
      ],
      repeatDeductionList:[],
      problemShow:false,
      scoreStatisticsShow:false,
      jinyu: [],
      problemNumList:[],
      companyList: [],
      date: ['', ''],
      loading: false,
      tableHeight: '',
      form1: {},
      type:'',
      scoreStatisticsList:{},
      pageSizeArray: [10, 20, 50],
      pagedata: {
        total: 0,
        pageSize: 10,
        currentPage: 1,
      },
      groupNumShow: false,
      groupGradeShow: false,
      groupGradeColumn:{},
      groupGradeColumnShow: false,
      companyId: sessionStorage('userId').getObject('userId').companyId,
      dataTable: [],
      columns1: [

        {
          title: "序号",
          width: 80,
          align: "center",
          fixed: 'left',
          render: (h, params) => {
            return h('span', params.index + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
          }
        },
        {
          title: '二级集团',
          minWidth: 280,
          align: 'center',
          key: 'twoOrgName',
        },
        {
          title: '审计单位',
          minWidth: 280,
          align: 'center',
          key: 'orgName',
        },
        {
          title: '审计计划',
          minWidth: 150,
          align: 'center',
          key: 'auditPlanName',
        },
        {
          title: '审计任务',
          minWidth: 150,
          align: 'center',
          key: 'missionName',
        },
        {
          title: '带队',
          minWidth: 80,
          align: 'center',
          key: 'supervisor',
        },
        {
          title: '组长',
          minWidth: 80,
          align: 'center',
          key: 'groupLeaderName',
        },

        {
          title: '成员',
          minWidth: 300,
          align: 'center',
          key: 'membersName',
        },
        {
          title: '基础标准得分',
          minWidth: 150,
          align: 'center',
          key: 'calculationBasicsScore',
        },
        {
          title: '现场标准得分',
          minWidth: 150,
          align: 'center',
          key: 'calculationSceneScore',
        },
        {
          title: '班组标准得分',
          minWidth: 150,
          align: 'center',
          key: 'calculationTeamScore',
        },
        {
          title: '总分',
          minWidth: 150,
          align: 'center',
          key: 'totalScore',
        },
        {
          title: '得分率',
          minWidth: 150,
          align: 'center',
          key: 'scoreRate',

        },
        {
          title: '最终得分',
          minWidth: 150,
          align: 'center',
          key: 'finalScore',

        },
        {
          title: '评级',
          minWidth: 150,
          align: 'center',
          key: 'level',

        }

      ],
      companyAll:[],
      model1: false,
      model2: false,
      buttonDisabled: false,
      InputData: {},
      statistical: {},
      basics: [],
      scene: [],
      team: [],
    }
  },
  mounted() {
    this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
    // this.query()
    this.selectCodingSort();


  },
  methods: {
    selects() {
      if (this.form1.auditOrgId){
        this.selectGroupGradeColumn()
        this.selectScoreStatistics()
        this.repeatDeductions()
        this.getMissionScore()
        if (this.form1.auditPlanId) {
          // this.selectAll();
          this.deductionTop5();
          this.selectProblemNum();
        }else{
          this.$Message.warning("请先选择审计计划")
        }
      }else{
        this.$Message.warning("请选择企业名称")
      }

    },
    queryCompanyList(){
      let _this = this;
      if (this.form1.auditPlanId){
        this.$http.get(Api.queryAuditCompanyList + "/" + sessionStorage('userId').getObject('userId').userId ,
            {params:{planId:this.form1.auditPlanId}}).then((res) => {
          _this.companyList = res.data.data;
          if (_this.companyList.length == 0) {
            this.$Message.warning("没有找到相关的被审计单位")
          }
        });
      }

    },
    selectCodingSort() {
      let _this = this;
      this.$http.get(Api.getPlanAll).then((res) => {
        _this.jinyu = res.data.data.list;
        _this.form1.auditPlanId = res.data.data.plan.auditPlanId;
        this.queryCompanyList();
        this.selects();
      });
    },
    formatDate(date, fmt) {
      if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
      }
      let o = {
        'M+': date.getMonth() + 1,
        'd+': date.getDate(),
        'h+': date.getHours(),
        'm+': date.getMinutes(),
        's+': date.getSeconds()
      };
      for (let k in o) {
        if (new RegExp(`(${k})`).test(fmt)) {
          let str = o[k] + '';
          fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
        }
      }
      return fmt;
    },
    padLeftZero(str) {
      return ('00' + str).substr(str.length);
    },
    select() {

    },
    selectCompany(value){
      this.form1.auditPlanId = value;
      this.queryCompanyList();
    },
    query(name, type) {
      this.loading = true;
      let data = {
        startPage: this.pagedata.currentPage,
        size: this.pagedata.pageSize,
      };
      if (type === '1') {
        this.form1.twoOrgName = name;
        this.form1.level = null;
      } else if (type === '2') {
        this.form1.level = name;
        this.form1.twoOrgName = null;
      }
      data = Object.assign(data, JSON.parse(JSON.stringify(this.form1)));
      let url = Api.queryAuditRank;
      this.$http.get(url, {params: data}).then((res) => {
        this.dataTable = res.data.data.data;
        this.pagedata.total = res.data.data.totalSize;
        this.loading = false;
      }).catch(e => {
        this.$Message.error("数据获取失败")
      })
    },
    reset() {
      this.form1 = {

      }
      this.$refs.childOrg.resetCurrentOrg();
    },
    pageChange(pageNum) {
      this.pagedata.currentPage = pageNum;
      this.query();
    },
    pageSizeChange(pageSize) {
      this.pagedata.pageSize = pageSize;
      this.query();
    },
    selectAll(){
      let _this = this;
      _this.groupGradeShow = true;
      let companyAll = echarts.init(this.$refs.companyAll);
      if (!this.form1.auditOrgId){
        this.form1.auditOrgId = sessionStorage('userId').getObject('userId').companyId
      }
      this.$http.get(Api.companyAll ,{params: this.form1}).then((res) => {
        if(res.data.status == '200'){
          _this.companyAll = res.data.data;
        }else if(res.data.status = '202'){
          this.$Message.warning(res.data.msg);

        }
        let basicsOption = this.getCompanyAll();
        companyAll.setOption(basicsOption);
        window.onresize = companyAll.resize;
        _this.groupGradeShow = false;
      }).catch(e => {
        console.log(e)
        this.$Message.error("数据获取失败")
        _this.groupGradeShow = false;
      })
    },
    getCompanyAll() {
      let _this = this;
      let option = {
        title:{
          text:"问题汇总",
          left:'right'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          type: 'scroll',
          orient: 'vertical',
          left: 'left',

        },
        formatter(name) {
          const count = _this.arrCount(_this.companyAll);
          const val = _this.companyAll.filter(item => {
            return item.name === name
          })
          if (val.length != 0){
            return name + '  ' + val[0].value +'  ' +Number((((val[0].value / count).toFixed(4)) * 100).toString().match(/^\d+(?:\.\d{0,2})?/)) + '%'
          }
          return name;

        },
        toolbox: {
          top:30,
          feature:{
            saveAsImage:{type:'png'}
          }
        },
        color: ['#FD5C50', '#FF9800', '#FDD835', '#40C4FF', '#FF3E80', '#42A5F5', '#FFC310', '#1DE9B6', '#6666CC', '#66CC66','#16CF52','#22CA66'],
        series: [
          {
            name: '问题数量',
            type: 'pie',
            radius: '75%',
            data: this.companyAll,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      return option;

    },
    arrCount(arr) {
      let count = 0
      arr.forEach(item => {
        count = count + item.value
      })
      return count
    },
    selectGroupNum() {
      let _this = this;
      _this.groupNumShow = true;
      let basics = echarts.init(this.$refs.basics);
      let scene = echarts.init(this.$refs.scene);
      let team = echarts.init(this.$refs.team);
      this.basics = [];
      this.scene = [];
      this.team = [];
      if (!this.form1.auditOrgId){
        this.form1.auditOrgId = sessionStorage('userId').getObject('userId').companyId
      }
      this.$http.get(Api.companyNum ,{params: this.form1}).then((res) => {
        if(res.data.status == '200'){
          _this.basics = res.data.data.basics.proMappings;
          _this.scene = res.data.data.scene.proMappings;
          _this.team = res.data.data.team.proMappings;


        }else if(res.data.status = '202'){
          this.$Message.warning(res.data.msg);

        }
        let basicsOption = this.getBasics();
        let sceneOption = this.getScene();
        let teamOption = this.getTeam();
        basics.setOption(basicsOption);
        scene.setOption(sceneOption);
        team.setOption(teamOption);
        window.onresize = basics.resize;
        window.onresize = scene.resize;
        window.onresize = team.resize;

        _this.groupNumShow = false;
      }).catch(e => {
        console.log(e)
        this.$Message.error("数据获取失败")
        _this.groupNumShow = false;
      })
    },
    //审计基础标准
    getBasics() {
      let _this = this;
      let option = {
        title:{
          text:"安全审计基础问题",
          left:'right'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          type: 'scroll',
          orient: 'vertical',
          left: 'left',

        },
        formatter(name) {
          const count = _this.arrCount(_this.basics);
          const val = _this.basics.filter(item => {
            return item.name === name
          })
          if (val.length != 0){
            return name + '  ' + val[0].value +'  ' +Number((((val[0].value / count).toFixed(4)) * 100).toString().match(/^\d+(?:\.\d{0,2})?/)) + '%'
          }
          return name;

        },
        toolbox: {
          top:30,
          feature:{
            saveAsImage:{type:'png'}
          }
        },
        color: ['#FD5C50', '#FF9800', '#FDD835', '#40C4FF', '#FF3E80', '#42A5F5', '#FFC310', '#1DE9B6', '#6666CC', '#66CC66','#16CF52','#22CA66'],
        series: [
          {
            name: '问题数量',
            type: 'pie',
            radius: '75%',
            data: this.basics,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      return option;

    },

    //审计现场
    getScene() {
      let _this = this;
      let option = {
        title:{
          text:"安全审计现场问题",
          left:'right',
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          type: 'scroll',
          orient: 'vertical',
          left: 'left',

        },
        toolbox: {
          top:30,
          feature:{
            saveAsImage:{type:'png'}
          }
        },
        formatter(name) {
          const count = _this.arrCount(_this.scene);
          const val = _this.scene.filter(item => {
            return item.name === name
          })
          if (val.length != 0){
            return name + '  ' + val[0].value +'  ' +Number((((val[0].value / count).toFixed(4)) * 100).toString().match(/^\d+(?:\.\d{0,2})?/)) + '%'
          }
          return name;

        },
        color: ['#FD5C50', '#FF9800', '#FDD835', '#40C4FF', '#FF3E80', '#42A5F5', '#FFC310', '#1DE9B6', '#6666CC', '#66CC66','#16CF52','#22CA66'],
        series: [
          {

            name: '问题数量',
            type: 'pie',
            radius: '75%',
            data: this.scene,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      return option;

    },
    //审计班组
    getTeam() {
      let _this = this;
      let option = {
        title:{
          text:"安全审计班组问题",
          left:'right'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          type: 'scroll',
          orient: 'vertical',
          left: 'left',

        },
        toolbox: {
          top:30,
          feature:{
            saveAsImage:{type:'png'}
          }
        },
        formatter(name) {
          const count = _this.arrCount(_this.team);
          const val = _this.team.filter(item => {
            return item.name === name
          })
          if (val.length != 0){
            return name + '  ' + val[0].value +'  ' +Number((((val[0].value / count).toFixed(4)) * 100).toString().match(/^\d+(?:\.\d{0,2})?/)) + '%'
          }
          return name;

        },
        color: ['#FD5C50', '#FF9800', '#FDD835', '#40C4FF', '#FF3E80', '#42A5F5', '#FFC310', '#1DE9B6', '#6666CC', '#66CC66','#16CF52','#22CA66'],
        series: [
          {

            name: '问题数量',
            type: 'pie',
            radius: '75%',
            data: this.team,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      return option;

    },

    selectProblemNum(){
      let _this = this;
      _this.problemShow = true;
      let container = echarts.init(this.$refs.problemNum);
      this.$http.get(Api.getCompanyProblemNum +"/" +_this.form1.auditPlanId + "/" +_this.form1.auditOrgId).then((res) => {
        _this.problemNumList = res.data.data;
        let option = this.getProblemNum();
        container.setOption(option);
        window.onresize = container.resize;
        _this.problemShow = false;
      }).catch(e => {
        _this.problemShow = false;
        this.$Message.error("数据获取失败")
      })

    },

    getProblemNum(){
      let option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            // Use axis to trigger tooltip
            type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
          }
        },
        legend: {},
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'value',
          splitLine: {show: false},
          axisTick: {show: false},
          axisLine: {show: false}
        },
        yAxis: {
          axisLine: {
            show: false,
          },
          data: [  '已完成整改数量', '班组问题数量','已完成整改数量','现场问题数量', '已完成整改数量','基础问题数量'],
          axisTick: {show: false}
        },
        series: [
          {
            label: {
              show: true
            },
            type: 'bar',
            itemStyle: {
              normal: {
                //这里是重点
                color: function(params) {
                  //注意，如果颜色太少的话，后面颜色不会自动循环，最好多定义几个颜色
                  //,
                  var colorList =['#FFC310', '#FF9800', '#FD5C50','#f34317' , '#42A5F5', '#40C4FF',   ];
                  return colorList[params.dataIndex]
                }
              }
            },
            data: this.problemNumList
          }
        ]
      };
      return option;
    },

    selectGroupGradeColumn() {
      let _this = this;
      _this.groupGradeColumnShow = true;
      let container = echarts.init(this.$refs.groupGradeColumn);
      this.$http.get(Api.getAllCompanyProblemCount + _this.form1.auditOrgId).then((res) => {
        this.groupGradeColumn = res.data.data;
        let option = this.getGroupGradeColumn();
        container.setOption(option);
        window.onresize = container.resize;
        _this.groupGradeColumnShow = false;
      }).catch(e => {
        this.$Message.error("数据获取失败")
        _this.groupGradeColumnShow = false;
      })
    },
    getGroupGradeColumn() {
      let option = {
        tooltip: {	//提示框组件
          trigger: 'axis',
          axisPointer: {            // 坐标轴指示器，坐标轴触发有效
            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
          }
        },
        legend: {	//图例组件
          // x:"right",
          bottom:1,
          data: ['基础问题数量', '现场问题数量', '班组问题数量', '问题总数',]
        },
        color: ['#FD5C50', '#FF9800', '#FDD835', '#40C4FF', '#FF3E80', '#42A5F5', '#FFC310', '#1DE9B6', '#6666CC', '#66CC66'],
        grid: {
          left: '3%',
          right: '3%',
          bottom: '8%',
          containLabel: true,
        },

        xAxis: [
          {
            type: 'category',
            data: this.groupGradeColumn.planNames,
            axisTick: {show: false},
            axisLine: {show: false},
            axisLabel: {
              interval: 0,
              formatter: function (value) {
                var str = "";
                var num = 10; //每行显示字数
                var valLength = value.length; //该项x轴字数
                var rowNum = Math.ceil(valLength / num); // 行数
                if (rowNum > 1) {
                  for (var i = 0; i < rowNum; i++) {
                    var temp = "";
                    var start = i * num;
                    var end = start + num;
                    temp = value.substring(start, end) + "\n";
                    str += temp;
                  }
                  return str;
                } else {
                  return value;
                }
              }
            }
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: '基础问题数量',
            type: 'bar',
            stack:'group',
            barWidth : 30,
            emphasis: {
              focus: 'series'
            },
            data: this.groupGradeColumn.basics
          },
          {
            name: '现场问题数量',
            type: 'bar',
            stack:'group',
            barWidth : 30,
            emphasis: {
              focus: 'series'
            },
            data: this.groupGradeColumn.scene
          },
          {
            name: '班组问题数量',
            type: 'bar',
            stack:'group',
            barWidth : 30,
            emphasis: {
              focus: 'series'
            },
            data: this.groupGradeColumn.team
          },
          {
            name: '问题总数',
            type: 'bar',
            stack:'group',
            barWidth : 30,
            emphasis: {
              focus: 'series'
            },
            data: this.groupGradeColumn.totals
          },
        ]
      };
      return option;

    },


    getScoreStatistics(){
      let option = {
        xAxis: {
          type: 'category',
          data: this.scoreStatisticsList.plans,
        },
        tooltip: {
          trigger: 'axis'
        },
        color: ['#40C4FF', '#FDD835', '#22CA66'],
        yAxis: {
          type: 'value'
        },
        legend: {
          data: ['基础', '现场', '班组'],
          y: 'bottom',
        },
        series: [
          {
            name: '基础',
            type: 'line',
            stack: 'Total',
            emphasis: {
              focus: 'series'
            },
            data: this.scoreStatisticsList.basics,
          },
          {
            name: '现场',
            type: 'line',
            stack: 'Total',
            emphasis: {
              focus: 'series'
            },
            data: this.scoreStatisticsList.scenes,
          },
          {
            name: '班组',
            type: 'line',
            stack: 'Total',
            emphasis: {
              focus: 'series'
            },
            data: this.scoreStatisticsList.teams,
          },
        ]
      };
      return option;
    },
    parseScoreStatistics(data) {
      if (data.length == 0) {
        return [];
      }
      let list = {
        basics: [],
        scenes: [],
        teams: [],
        plans: [],
      }
      data.forEach(item => {
        list["plans"].push(item.planName);
        list["basics"].push(item.basicsProblemNum);
        list["scenes"].push(item.sceneProblemNum);
        list["teams"].push(item.teamProblemNUm);
      })
      return list;

    },
    selectScoreStatistics() {
      let _this = this;
      _this.scoreStatisticsShow = true;
      let container = echarts.init(this.$refs.scoreStatistics);
      this.$http.get(Api.getScoreStatistics + _this.form1.auditOrgId).then((res) => {

        this.scoreStatisticsList = _this.parseScoreStatistics(res.data.data);
        let option = this.getScoreStatistics();
        container.setOption(option);
        window.onresize = container.resize;
        _this.scoreStatisticsShow = false;
      }).catch(e => {
        this.$Message.error("数据获取失败")
        _this.scoreStatisticsShow = false;
      })
    },
    getMissionScoreOption(data) {
      let option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: {
          data: ['Forest', 'Steppe', 'Desert', 'Wetland']
        },
        xAxis: [
          {
            type: 'category',
            axisTick: {show: false},
            data: data.plans
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        color: ['#FD5C50', '#FF9800', '#FDD835', '#40C4FF'],
        series: [
          {
            name: '基础',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: data.basics
          },
          {
            name: '现场',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: data.scene
          },
          {
            name: '班组',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: data.team
          },
          {
            name: '总分',
            type: 'line',
            emphasis: {
              focus: 'series'
            },
            data: data.totalScores
          },
        ]
      }
      return option
    },
    parseMissionScore(data) {
      let list = {
        plans: [],
        basics: [],
        scene: [],
        totalScores: [],
        team: [],
      }
      data.forEach(item => {
        list.plans.push(item.planName)
        list.basics.push(item.basics)
        list.totalScores.push(item.totalScore)
        list.scene.push(item.scene)
        list.team.push(item.team)
      })
      return list;
    },
    getMissionScore() {
      let _this = this;
      _this.missionScoreShow = true;
      this.$http.get(Api.getLevelByOrg + _this.form1.auditOrgId).then((res) => {
        if (res.data.status == '200') {
          _this.missionScoreList = res.data.data;
        }
        _this.missionScoreShow = false;
      }).catch(e => {
        this.$Message.error("数据获取失败")
        _this.missionScoreShow = false;
      })
    },
    repeatDeductions() {
      let _this = this;
      _this.repeatDeductionsShow = true;

      this.$http.get(Api.repeatDeductions + _this.form1.auditOrgId).then((res) => {
        if (res.data.status == '200') {
          _this.repeatDeductionList = res.data.data
        }
        _this.repeatDeductionsShow = false;
      }).catch(e => {
        _this.repeatDeductionsShow = false;
        this.$Message.error("数据获取失败")
      })

    },

    deductionTop5() {
      let _this = this;
      _this.deductionShow = true;

      this.$http.get(Api.getProblemDeductionTop5 + "/" + _this.form1.auditPlanId + "/" + _this.form1.auditOrgId).then((res) => {
        debugger;
        if (res.data.status == '200') {
          _this.deductionTop5List = res.data.data
        }
        _this.deductionShow = false;
      }).catch(e => {
        _this.deductionShow = false;
        this.$Message.error("数据获取失败")
      })

    },


  }
}
</script>

<style scoped>
@import '../../../../index.css';

.demo-spin-icon-load {
  animation: ani-demo-spin 1s linear infinite;
}

.card-row {
  margin-bottom: 10px;
}

p {
  display: inline-block;
  font-size: 18px;
}

.p-title {
  display: inline-block;
  line-height: 27px;
  font-size: 18px;
  height: 27px;
  color: red;
}

</style>
